<!DOCTYPE html>
<html>
	<#assign contextPath = request.contextPath/> 
	<head>
		<meta charset="UTF-8">
		<title>新增投票</title>
		<link href="${contextPath}/css/bootstrap.min.css" rel="stylesheet">
		<script type="text/javascript" src="${contextPath}/js/jquery-3.0.0.min.js"></script>
	</head>

	<body>
		<#include "/common/nav.html">
		<div class="container-fluid">
			<div class="row">
				<#include "/common/left.html">
				<div class="col-sm-9">
					<ol class="breadcrumb">
						<li>
							<a href="#">主页</a>
						</li>
						<li class="active">新增投票</li>
					</ol>
					<form class="form-horizontal" id="addvoteform" action="savevote.action" method="post">
						<div class="form-group">
							<label for="title" class="col-sm-2 control-label">投票类型</label>
							<div class="col-sm-10">
								<select class="form-control" name="e.voteType.vtId" style="width: 100px;">
									<#list vtlist as vt>
									<option value="${vt.vtId}">${vt.vtName}</option>
									</#list>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-2 control-label">投票标题</label>
							<div class="col-sm-10">
								<input type="text" name="e.vtitle" class="form-control" id="title" placeholder="投票标题" >
							</div>
						</div>
						<div class="form-group ops">
							<label for="options1" class="col-sm-2 control-label">选项1</label>
							<div class="col-sm-10">
								<input type="text" name="e.voteOptions.makeNew[0].voText" class="form-control" id="options1" placeholder="选项1">
							</div>
						</div>
						<div class="form-group ops">
							<label for="options2" class="col-sm-2 control-label">选项2</label>
							<div class="col-sm-10">
								<input type="text" name="e.voteOptions.makeNew[1].voText" class="form-control" id="options2" placeholder="选项2">
							</div>
						</div>
						<div class="form-group" id="addop">
							<div class="col-sm-offset-2 col-sm-10">
								<button type="button" class="btn btn-link" onclick="addop()">新增选项</button>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-10">
								<button type="submit" class="btn btn-info">新增</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script>
			function addop() {
				var length = $(".ops").length;
				length++;
				var html = "<div class='form-group ops'>";
				html += "<label for='options" + length + "' class='col-sm-2 control-label'>选项" + length + "</label>";
				html += "<div class='col-sm-10'>";
				html += "<input type='text' name='e.voteOptions.makeNew["+(length-1)+"].voText' class='form-control' id='options" + length + "' placeholder='选项" + length + "' required>";
				html += "</div></div>";
				$("#addop").before(html);
			}
			
		</script>
	</body>

</html>